import { defineStore } from 'pinia';
import { getUserInfo } from '@/api/user/index.ts'
const useUserStore = defineStore('user', {
    state: () => ({
        user: JSON.parse(localStorage.getItem('user') as string)
    }),
    actions: {
        async getInfo() {
            const user = await getUserInfo(JSON.parse(localStorage.getItem('user') as string)._id)
            this.user = user.data
            localStorage.setItem('user', JSON.stringify(user.data))
        }
    }
})

export default useUserStore;